package uk.co.hephistocles.blobGame;

import java.util.LinkedList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.MoveTo;
import com.badlogic.gdx.scenes.scene2d.actors.Image;
import com.badlogic.gdx.scenes.scene2d.actors.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Button.ClickListener;

public class Dialog implements InputProcessor {
	public Stage 	menu;
	
	public Dialog() {
		menu = new Stage(Gdx.graphics.getWidth(),Gdx.graphics.getHeight(),true);
	}
	public Button addButton(String name, String label, BitmapFont font,
			NinePatch dwnBtn, NinePatch upBtn, ClickListener click) {
		return addButton(name, label, font, dwnBtn, upBtn, click, Color.BLACK);
	}
	public Button addButton(String name, String label, BitmapFont font,
			NinePatch dwnBtn, NinePatch upBtn, ClickListener click, Color color) {
		Button myButton = new Button(name, label, new ButtonStyle(font, 
				color,dwnBtn,upBtn));
		myButton.setClickListener(click);
		menu.addActor(myButton);
		return myButton;
	}

	public Image addImage(String name, Texture tex, int x, int y) {
		return addImage(name, new TextureRegion(tex), x, y);
	}
	public Image addImage(String name, TextureRegion tex, int x, int y) {
		Image img = new Image(name, tex);
		img.x = x;
		img.y = y;
		img.touchable = false;
		menu.addActor(img);
		return img;
	}
	public Image addImage(Image img) {
		menu.addActor(img);
		return img;
	}
	
	public AnimatedImage addAnimImage(String name, Texture tex, int x, int y, int width, int height, int frames, int sheetWidth) {
		AnimatedImage img = new AnimatedImage(name, tex, width, height, frames, sheetWidth, Game.fps);
		img.x = x;
		img.y = y;
		img.touchable = false;
		menu.addActor(img);
		return img;
	}
	public AnimatedImage addAnimImage(String name, TextureRegion region, int x, int y, int width, int height, int frames, int sheetWidth) {
		AnimatedImage img = new AnimatedImage(name, region, width, height, frames, sheetWidth, Game.fps);
		img.x = x;
		img.y = y;
		img.touchable = false;
		menu.addActor(img);
		return img;
	}
	
	public void dispose() {
		menu.clear();
		menu.dispose();
	}
	
	public Label addLabel(String name, String label, BitmapFont font, Color color) {
		Label lbl = addLabel(name, label, font, color,0,0);
		lbl.x = (Gdx.graphics.getWidth()-lbl.width)/2;
		lbl.x = (Gdx.graphics.getHeight()-lbl.height)/2;
		return lbl;
	}
	public Label addLabel(String name, String label, BitmapFont font, Color color, int x, int y) {
		font.setColor(color);
		Label lbl = new Label(name, font, label);
		lbl.x = x;
		lbl.y = y;
		lbl.touchable = false;
		menu.addActor(lbl);
		return lbl;
	}
	
	public void clear() {
		menu.clear();
	}
	public void update(float dt) {
		menu.act(dt);
	}
	public void draw() {
		menu.draw();		
	}


    @Override public boolean touchDown (int x, int y, int pointer, int button) {
        menu.touchDown(x, y, pointer, button);
        return false;
    }

    @Override public boolean touchUp (int x, int y, int pointer, int button) {
        menu.touchUp(x, y, pointer, button);
        return false;
    }

    
    @Override
    public boolean touchDragged (int x, int y, int pointer) {     
        menu.touchDragged(x, y, pointer);
        return false;
    }
    
    @Override public boolean touchMoved (int x, int y) {
		menu.touchMoved(x, y);
        return false;
    }

    @Override public boolean scrolled (int amount) {
        return false;
    }
    
    @Override public boolean keyDown (int keycode) { return false; }
    @Override public boolean keyUp (int keycode) { return false; }
    @Override public boolean keyTyped (char character) { return false; }
}
